﻿using Common;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Regions;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;
using WPF01.Models;

namespace WPF01.ViewModels
{
    public class MainWindowViewModel : BindableBase
    {
        private string _title = "WPF 20241116";
        public string Title
        {
            get { return _title; }
            set { SetProperty(ref _title, value); }
        }
        #region Command
        public ICommand RegionCommand { get; set; }
        public ICommand CloseCommand { get; set; }
        #endregion

        public ObservableCollection<MenuModel> MenuModels { get; set; }

        public MainWindowViewModel(IRegionManager regionManager)
        {
            RegionCommand = new DelegateCommand<string>(viewName => {
                //regionManager.RegisterViewWithRegion(Contracts.RegionName, viewName); //注册页面，可以注册多个，ContentControl只能显示一个
                regionManager.RequestNavigate(Contracts.RegionName, viewName);
            });
            CloseCommand = new DelegateCommand<ICloseWindow>(window => window.CloseWindow());
            MenuModels = new ObservableCollection<MenuModel>();
            MenuModels.Add(new MenuModel("跨层级绑定命令", Contracts.Freezable) { });
            MenuModels.Add(new MenuModel("自定义控件", Contracts.ShowCustomControl) { });
            MenuModels.Add(new MenuModel("Adorner", Contracts._Adorner) { });
            MenuModels.Add(new MenuModel("依赖属性继承性", Contracts.BaseOn) { });
            MenuModels.Add(new MenuModel("行为", Contracts.UCBehavior) { });
            MenuModels.Add(new MenuModel("Radio绑定VM", Contracts.TRadioButton) { });
        }
    }
}
